<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        function getNews(data) {
            console.log(data);
        }
    </script>
</head>
<body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
    function formatterDateTime() {
        var date=new Date()
        var month=date.getMonth() + 1
        var datetime = date.getFullYear()
            + ""// "年"
            + (month >= 10 ? month : "0"+ month)
            + ""// "月"
            + (date.getDate() < 10 ? "0" + date.getDate() : date
                .getDate())
            + ""
            + (date.getHours() < 10 ? "0" + date.getHours() : date
                .getHours())
            + ""
            + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
                .getMinutes())
            + ""
            + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
                .getSeconds());
        return datetime;
    }

    $.ajax({
        type: 'post',
        url: 'http://route.showapi.com/181-1',
        dataType: 'json',
        data: {
            "showapi_timestamp": formatterDateTime(),
            "showapi_appid": '67695', //这里需要改成自己的appid
            "showapi_sign": '49495bb2af264a45a65b4d76a508e3a5',  //这里需要改成自己的应用的密钥secret
            "num":"10",
            "rand":"1",

            "page":"1",
            "src":"人民日报"

        },

        error: function(XmlHttpRequest, textStatus, errorThrown) {
            alert("操作失败!");
        },
        success: function(result) {
            var data=result.showapi_res_body.newslist; //console变量在ie低版本下不能用
            Createnewslist(data);
        }
    });

    function Createnewslist(data) {
        for (var key in data){
            console.log(key)
        }

    }
</script>
</body>
</html>